package com.xuerhua.yxt.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xuerhua.yxt.common.Const;
import com.xuerhua.yxt.common.MenuConst;
import com.xuerhua.yxt.common.RspResult;
import com.xuerhua.yxt.common.enums.Status;
import com.xuerhua.yxt.model.FinalTermScoreReport;
import com.xuerhua.yxt.reqVo.BaseQueryVO;
import com.xuerhua.yxt.service.IFinalTermScoreReportService;


/**
 * @author huhekun
 * @date 2020/1/7
 * @description 云校通-家长端 期末成绩报告查询
 */
@Controller
@RequestMapping(Const.STUDENT_ROLE + MenuConst.SCORE_REPORT)
public class StudentScoreReportController extends BaseController {

    private Logger logger = LoggerFactory.getLogger(StudentScoreReportController.class);

    @Autowired
    private IFinalTermScoreReportService finalTermScoreReportService;

    /**
     * @author huhekun
     * @date 2020/1/7
     * @description 跳转到家长版的期末成绩查询页面
     */
    @RequestMapping(value = {"", "/"})
    public String studentScoreReport(Model model) {
        model.addAttribute("student", getAppUser().getParent());
        return "student/studentReport";
    }

    /**
     * @author huhekun
     * @date 2020/1/7
     * @description 查询操作, 表格渲染
     */
    @ResponseBody
    @RequestMapping(value = "/studentGrade", method = RequestMethod.POST)
    public Object getStudentGrade(BaseQueryVO vo) {
        vo.setSchoolId(getAppUser().getParent().getSchoolId());
        FinalTermScoreReport finalTermScoreReport = finalTermScoreReportService.selectStudentTermReport(vo);
        return new RspResult(Status.SUCCESS, finalTermScoreReport);
    }

}
